const ENV = process.env.NODE_ENV;
import axios from 'axios';
let BASE_URL = '';
const p = new Promise((resolve, reject) => {
  axios.get('config/app-config.json')
    .then((res) => {
      if (ENV === 'development') {
        // 本地线下地址
        // BASE_URL = 'http://115.239.175.246:5501/capital_back';
        // BASE_URL = ' http://115.239.175.246:5503/capital_back';
        // BASE_URL = 'http://115.239.175.246:5902/capital_back'; // 98外网
        // 大富本地
        // basePath = 'http://10.10.10.123:8888';
        BASE_URL = 'http://10.10.10.31:8081/capital_back';
        // BASE_URL = 'http://10.10.10.32:8081/capital_back';
        // BASE_URL = 'http://10.10.10.52:6081/capital_back';
        // BASE_URL = 'http://10.10.10.52:6080/capital_back';
        // BASE_URL = 'http://10.10.10.61:8081/capital_back';
        // BASE_URL = 'http://10.10.10.95:8081/capital_back';
        // BASE_URL = 'http://10.10.10.98:8081/capital_back';
        resolve({
          url: BASE_URL,
          res: res
        });
      } else {
        // 根据字段去判断是写地址还是自动获取浏览器上的地址
        if (res.data.isAutoGet === '0') {
          resolve({
            url: res.data.baseUrl,
            res: res
          });
        } else {
          const autoUrl = `http://${window.location.host}/capital_back`;// 动态接口地址
          resolve({
            url: autoUrl,
            res: res
          });
        }
      }
    });
});
export default () => {
  return p;
};
